#ifndef IUSERDICT_H
#define IUSERDICT_H

#include <QObject>
#include <QVector>

// 前置声明
struct PinyinCandidate;
class PinyinGeneratorInterface;

// 虚继承QObject，解决菱形继承问题
class IUserDict : public virtual QObject
{
	Q_OBJECT
	
public:
    virtual ~IUserDict() = default;

    // 数据库初始化
    virtual bool initDatabase() = 0;

    // 用户词CRUD操作
    virtual bool addWord(const QString &word, const QString &pinyin = "", int frequency = 1) = 0;
    virtual bool removeWord(const QString &word) = 0;
    virtual bool updateFrequency(const QString &word, int increment = 1) = 0;
    virtual QVector<PinyinCandidate> queryWords(const QString &pinyin) = 0;

    // 词库状态检查
    virtual bool isConnected() const = 0;
    virtual bool wordExists(const QString &word) = 0;

    // 扩展功能
    virtual bool exportDict(const QString &exportPath, bool encrypt = true) = 0;
    virtual bool importDict(const QString &importPath) = 0;
    virtual int getWordCount() const = 0;
    virtual void setPinyinGenerator(PinyinGeneratorInterface* generator) = 0;

signals:
    virtual void dictChanged() = 0;
    virtual void databaseError(const QString &errorMsg) = 0;

};

#endif	// IUSERDICT_H